﻿{include file="public/header"}
<title>店长列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 客户管理
    <span class="c-gray en">&gt;</span> 客户列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">

    <a style="text-decoration:none" class="btn btn-primary add "  href="javascript:;" title="新增"><span class="label label-primary">新增</span></a>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
            <tr class="text-c">
                <th width="50">序号</th>
                <th width="100">优惠金额</th>
                <th width="100">类别</th>
                <th width="50">使用条件</th>
                <th width="100">过期时间</th>
                <th width="100">当前状态</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name='list' id='vo'}
            <tr class="text-c">
                <td>{$vo.youhui_id}</td>
                <td>{$vo.jine}</td>
                <td> {if condition="$vo.leibie == 1"} 定金
                {elseif condition="$vo.leibie == 2"/}中期款
                {elseif condition="$vo.leibie == 3"/}尾款
                {/if}</td>
                <td>{$vo.tiaojan}</td>
                <td> {if condition="$vo.lalst_time"}{:date('Y-m-d',$vo.lalst_time)}{else}暂无{/if}</td>
                <td>   {if condition="$vo.status == 0"} 正常
                    {elseif condition="$vo.status == 1"/}禁用
                    {elseif condition="$vo.status == 2"/}删除
                    {/if}</td>
                <td class="td-manage">
                    {if condition="$vo.status == 0"}
                    <a style="text-decoration:none" class="ml-5 edit button" data-id="{$vo.youhui_id}" href="javascript:;" title="编辑"><span class="label label-primary">编辑</span></a>
                    <a style="text-decoration:none" class="ml-5 disable button" data-id="{$vo.youhui_id}" data-status="1" href="javascript:;" title="禁用"><span class="label label-danger">禁用</span></a>
                    {/if}

                    {if condition="$vo.status == 1"}
                    <a style="text-decoration:none" class="ml-5 disable button" data-id="{$vo.youhui_id}" data-status="0" href="javascript:;" title="启用"><span class="label label-success">启用</span></a>
                    <a style="text-decoration:none" class="ml-5 edit button" data-id="{$vo.youhui_id}" href="javascript:;" title="编辑"><span class="label label-primary">编辑</span></a>
                    {/if}

                    <a style="text-decoration:none" class="ml-5 del button" data-id="{$vo.youhui_id}" href="javascript:;" title="删除"><span class="label label-danger">删除</span></a>


                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div class="pages" style="float: right">{$list->render()}</div>

    </div>
</div>

{include file="public/footer"}
<script type="text/javascript">
    function selecttime(flag) {
        if (flag == 1) {
            var endTime = $("#countTimeend").val();
            if (endTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', maxDate: endTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        } else {
            var startTime = $("#countTimestart").val();
            if (startTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', minDate: startTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        }
    }

    $('.edit').click(function () {
        var id=$(this).attr('data-id');
        var src="{:Url('index/youhui/edit')}";
        layer.open({
            type: 2,
            area: ['35%', '60%'],
            fix: false,
            maxmin: true,
            shade:0.4,
            title: '处理意见',
            content: src+'?youhui_id='+id
        });
        layer.full(index);
    });



    /**
     * 禁用/启用
     */
    $('.disable').click(function () {
        var id=$(this).attr('data-id');
        var status=$(this).attr('data-status');
        var obj={};
        obj.youhui_id=id;
        obj.status=status;
        var str='确认要启用该用户吗？';
        if(status==1){
            str='确认要禁用该用户吗？';
        }
        var src="{:Url('index/youhui/disable')}";
        layer.confirm(str, function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (res) {
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:3000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });

    /**
     * 删除
     */
    $('.del').click(function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.youhui_id=id;
        var src="{:Url('index/youhui/del')}";
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });
    /**
     * 添加
     */
    $('.add').click(function () {

        var src="{:Url('index/youhui/add')}";
        layer.open({
            type: 2,
            area: ['35%', '60%'],
            fix: false,
            maxmin: true,
            shade:0.4,
            title: '处理意见',
            content: src
        });
        layer.full(index);
    });


</script>
</body>
</html>